package org.pentaho.actioneditor.client.processpanels;

import com.google.gwt.user.client.ui.*;
import org.pentaho.actioneditor.client.messages.Messages;
import com.google.gwt.user.client.Command;


public class InputUI {

  private VerticalPanel root = new VerticalPanel();
  private TextBox name = new TextBox();
  private ListBox type = new ListBox();
  private MenuBar addInputSource = new MenuBar();
  private MenuItem sourceUp = new MenuItem(Messages.getUIInstance().inputui__0000(), (Command)null);
  private MenuItem sourceDown = new MenuItem(Messages.getUIInstance().inputui__0001(), (Command)null);
  public static interface ItemCommand {
    public void execute(String text);
  }  public static interface CommandHelper {
    public Command getCommand(MenuItem item);
  }
  ItemCommand addSourceCommand;
  CommandHelper addSourceCommandHelper;
  private MenuItem deleteSource = new MenuItem(Messages.getUIInstance().inputui_X(), (Command)null);
  private ScrollPanel tableScroller = new ScrollPanel();
  private CheckBox hasDefaultValue = new CheckBox(Messages.getUIInstance().inputui_HasDefaultvalue());
  private VerticalPanel defaultValueBox = new VerticalPanel();


  public void init() {
    HorizontalPanel obj125 = new HorizontalPanel();
    VerticalPanel obj126 = new VerticalPanel();
    Label obj127 = new Label(Messages.getUIInstance().inputui_Name());
    obj126.add(obj127);
    obj126.add(name);
    Label obj128 = new Label(Messages.getUIInstance().inputui_Type());
    obj126.add(obj128);
    type.addItem(Messages.getUIInstance().inputui_String());
    type.addItem(Messages.getUIInstance().inputui_Integer());
    type.addItem(Messages.getUIInstance().inputui_Long());
    type.addItem(Messages.getUIInstance().inputui_Bigdecimal());
    type.addItem(Messages.getUIInstance().inputui_List());
    type.addItem(Messages.getUIInstance().inputui_Stringlist());
    type.addItem(Messages.getUIInstance().inputui_Resultset());
    type.addItem(Messages.getUIInstance().inputui_Propertymap());
    type.addItem(Messages.getUIInstance().inputui_Propertymaplist());
    type.addItem(Messages.getUIInstance().inputui_Date());
    type.addItem(Messages.getUIInstance().inputui_Object());
    type.addItem(Messages.getUIInstance().inputui_Content());
    obj126.add(type);
    obj126.setWidth("50%");
    obj125.add(obj126);
    VerticalPanel obj129 = new VerticalPanel();
    Label obj130 = new Label(Messages.getUIInstance().inputui_SourceOfInput());
    obj129.add(obj130);
    VerticalPanel obj131 = new VerticalPanel();
    obj131.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    addInputSource.addItem(sourceUp);
    addInputSource.addItem(sourceDown);
    MenuItem obj132 = new MenuItem(Messages.getUIInstance().inputui_Add(), (Command)null);
    MenuBar obj133 = new MenuBar(true);
    MenuItem obj134 = new MenuItem(Messages.getUIInstance().inputui_Request(), (Command)null);
    obj133.addItem(obj134);
    obj134.setCommand(addSourceCommandHelper.getCommand(obj134));
    MenuItem obj135 = new MenuItem(Messages.getUIInstance().inputui_Session(), (Command)null);
    obj133.addItem(obj135);
    obj135.setCommand(addSourceCommandHelper.getCommand(obj135));
    MenuItem obj136 = new MenuItem(Messages.getUIInstance().inputui_Global(), (Command)null);
    obj133.addItem(obj136);
    obj136.setCommand(addSourceCommandHelper.getCommand(obj136));
    MenuItem obj137 = new MenuItem(Messages.getUIInstance().inputui_Runtime(), (Command)null);
    obj133.addItem(obj137);
    obj137.setCommand(addSourceCommandHelper.getCommand(obj137));
    MenuItem obj138 = new MenuItem(Messages.getUIInstance().inputui_Security(), (Command)null);
    obj133.addItem(obj138);
    obj138.setCommand(addSourceCommandHelper.getCommand(obj138));
    obj132.setSubMenu(obj133);
    addInputSource.addItem(obj132);
    addInputSource.addItem(deleteSource);
    obj131.add(addInputSource);
    obj131.setWidth("100%");
    obj129.add(obj131);
    tableScroller.setWidth("250px");
    tableScroller.setHeight("100px");
    tableScroller.setAlwaysShowScrollBars(true);
    obj129.add(tableScroller);
    obj129.setWidth("50%");
    obj125.add(obj129);
    obj125.setWidth("100%");
    root.add(obj125);
    DisclosurePanel obj139 = new DisclosurePanel(Messages.getUIInstance().inputui_DefaultValue(), true);
    VerticalPanel obj140 = new VerticalPanel();
    obj140.add(hasDefaultValue);
    obj140.add(defaultValueBox);
    obj139.add(obj140);
    obj139.setWidth("100%");
    root.add(obj139);
    root.setWidth("100%");

  }

  public VerticalPanel getRoot() {
    return root;
  }
  public TextBox getName() {
    return name;
  }
  public ListBox getType() {
    return type;
  }
  public MenuBar getAddInputSource() {
    return addInputSource;
  }
  public MenuItem getSourceUp() {
    return sourceUp;
  }
  public MenuItem getSourceDown() {
    return sourceDown;
  }
  public void setAddSourceCommand(ItemCommand itemCommand) {
    this.addSourceCommand = itemCommand;
    addSourceCommandHelper = new CommandHelper() {
      public Command getCommand(final MenuItem item) {
        Command cmd = new Command() {
          public void execute() {
            addSourceCommand.execute(item.getText());
          }
        };
        return cmd;
      }
    };
  }
  public MenuItem getDeleteSource() {
    return deleteSource;
  }
  public ScrollPanel getTableScroller() {
    return tableScroller;
  }
  public CheckBox getHasDefaultValue() {
    return hasDefaultValue;
  }
  public VerticalPanel getDefaultValueBox() {
    return defaultValueBox;
  }

}
